package cn.tedu.rabbitmqboot.m4;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Scanner;

@Component
public class Producer {
    @Autowired
    private AmqpTemplate amqpTemplate;

    // 需要手动调用,发送消息
    public void send() {
        while (true) {
            System.out.print("输入:");
            String msg = new Scanner(System.in).nextLine();
            System.out.print("输入路由键:");
            String key = new Scanner(System.in).nextLine();
            amqpTemplate.convertAndSend("direct_logs", key, msg);
        }
    }


}
